-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix inbetween-inserter position in RTL languages #49683
Conversation
Size Change: +1 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
Flaky tests detected in f9f8c4e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4656720564
|
// vertical, ltr | ||
left = previousRect ? previousRect.left : nextRect.left; | ||
} | ||
left = previousRect ? previousRect.left : nextRect.left; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why was the isRTL()
check here unnecessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just imagine this visually.
In LTR languages, the previous element is on the left of the next element but in RTL it's on the right. meaning that if we want to position a "div" between the two elements, its "left" coordinate should be the "right" coordinate of the "previous" element in LTR but it should be the "left" coordinate of the "next" element in RTL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I guess the question here is the "opposite". It's unnecessary here because in the case of the "vertical" in-between inserter, the "left" position is the same for both blocks anyway, so the left position of the empty space between them is also the same "left" position, so either prev.left or next.left. (and shouldn't be right in any case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the explanation — it makes sense to remove the RTL check for the vertical inserter :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is testing well for me
// vertical, ltr | ||
left = previousRect ? previousRect.left : nextRect.left; | ||
} | ||
left = previousRect ? previousRect.left : nextRect.left; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the explanation — it makes sense to remove the RTL check for the vertical inserter :)
closes #30867
What?
This PR fixes the position of the inbetween inserter in both vertical and horizontal position for RTL languages.
Testing Instructions
1- Switch to an RTL language (like arabic)
2- Insert two paragraphs and verify that you can trigger the in-between inserter at the right position
3- Insert a social links block with at least two links and verify that you can trigger the in-between horizontal inserter between two buttons.
I also noticed that if you use the "slash" inserter, the initial position is correct but as soon as you start typing, the position is wrong. I think that's unrelated with the issue being fixed here though and might be some race condition within "Popover" component.